
out vec4 FragmentColor;
in vec3 FragmentNormal;
in vec3 FragmentPosition;
uniform vec3 color;
uniform float FocalDistance;
uniform float BlurStrength;
void main(void)
{
    float d = dot(FragmentNormal, -normalize(FragmentPosition));
    d = abs(d);
    float s = pow(d,100) * sign(d);
    //if(d < 0.0)
    //    discard;
    float depth = FragmentPosition.z;
    //depth = (depth - 0.1) / (20.0 - 0.1);
    //depth = 1.0  - 1.0 / (1.0 - depth);
    //float foc = FocalDistance;
    float foc = (FocalDistance - 0.1) / (20.0 - 0.1);
    foc = 1.0 - 1.0 / (1.0 - foc);
    
	FragmentColor = vec4(color * (max(0.0, d) * 1.0 + 28.0f * max(0.0, s)),abs(foc - depth) * BlurStrength);
	//FragmentColor = vec4(d * color * FocalDistance, 1.0);
	//FragmentColor = vec4(FocalDistance, FocalDistance, FocalDistance, FocalDistance);
	
	//FragmentColor = vec4(1.0, 0.0, 0.0, 1.0) * (1.0 - length(vec3(0.0, 0.0, -3.0) - FragmentPosition) / 4.0);

}
